/**
 * Create by richliu1023
 * @date 2016-06-07
 * @email richliu1023@gmail.com
 * @github https://github.com/RichLiu1023
 * @description a simple explanation
 */
class NoticeController {

	private static _topNoticeLish:string[] = [];
	private static _topNoticeUI:TopNoticeUI;
	private static _bottomNoticeUI:BottomNoticeUI;

	public constructor() {
	}

	public static setup():void {
		this._topNoticeUI = new TopNoticeUI();
		this._topNoticeUI.addEventListener( TopNoticeUI.COMPLETE, this.onTopNoticeComplete, this );
		this._bottomNoticeUI = new BottomNoticeUI( GameConfig.STAGE_W / 2, GameConfig.STAGE_H / 2 );
	}

	public static showNotice( txt:string, type:number = NoticeTypeEnum.BOTTOM ):void {
		rm.log( txt );
		if ( type == NoticeTypeEnum.BOTTOM ) {
			this._bottomNoticeUI.execute( txt, UIController.noticeLayer );
		}
		else if ( type == NoticeTypeEnum.TOP ) {
			this._topNoticeLish.push( txt );
			this._topNoticeUI.isShow || this.onTopNoticeComplete();
		}
		else {
			egret.log( 'error: NoticeController Not Has Type !' );
		}
	}

	private static onTopNoticeComplete():void {
		if ( this._topNoticeLish.length == 0 )return;
		this._topNoticeUI.execute( this._topNoticeLish.shift(), GameConfig.STAGE_W, 0, UIController.noticeLayer );
	}
}